home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr37 / satsfaxt.zip / CCPUTILS.ZIP / ERROR.C < prev    next >
Text File  |  1990-01-30  |  13KB  |  182 lines

  1. /*===========================================================================*
  2.  *                                                                           *
  3.  *                                   ERROR.C                                 *
  4.  *                                                                           *
  5.  *---------------------------------------------------------------------------*
  6.  *                                                                           *
  7.  *  This module prints an error message corresponding to the error           *
  8.  *  number sent to it. Additionally, fatal errors will cause a termination   *
  9.  *  of the program returning the exit code associated with the error         *
  10.  *  message to DOS.                                                          *
  11.  *                                                                           *
  12.  *  CALL    : void CASError(int errornumber, int fatal, char *caller,        *
  13.  *                          int hwerrornumber);                              *
  14.  *  RETURN  : none (exit code returned to DOS on fatal errors)               *
  15.  *                                                                           *
  16.  *  The following source code is intended to assist developers in            *
  17.  *  creating applications which support the  DCA/Intel Communicating         *
  18.  *  Applications Specification Version 1.0A. It is provided free of charge   *
  19.  *  and on an as-is basis. THE IMPLIED WARRENTIES OF MERCHANTABILITY AND     *
  20.  *  FITNESS FOR A PARTICULAR PURPOSE ARE SPECIFICALLY EXCLUDED. This source  *
  21.  *  code may be modified, enhanced, copied and distributed with applications *
  22.  *  that support CAS on a royalty free basis.                                *
  23.  *                                                                           *
  24.  *---------------------------------------------------------------------------*
  25.  *                                                                           *
  26.  *  HISTORY:                                                                 *
  27.  *          - completed 9/14/89                                              *
  28.  *                                                                           *
  29.  *===========================================================================*/
  30.  
  31. #include <stdio.h>
  32. /*---------------------------------------------------------------------------*
  33.  *                                  CASError                                 *
  34.  *---------------------------------------------------------------------------*
  35.  *  This function prints an application error message.  If there is a CAS    *
  36.  *  error associated with the error, it too is printed out.  Finally, if     *
  37.  *  the error is fatal, the program is terminated with the proper exit code. *
  38.  *---------------------------------------------------------------------------*
  39.  *  INPUT :  error number, fatal indicator, calling process, CAS error #.    *
  40.  *  OUTPUT:  exit code if fatal.                                             *
  41.  *---------------------------------------------------------------------------*/
  42. #include <dos.h>
  43. #include "cas.h"
  44. #include "util.h"
  45.  
  46. #define UpperBound(a)   (sizeof(a)/sizeof(a[0]))
  47.  
  48. /* Application errors and exit codes. */
  49. ERRORMSG ErrorMsg[] = {
  50.     { 0, ""},
  51.     { 2, "CCAM not loaded, Resident manager must be installed prior to using this utility." },          /* CASNOHWO        */
  52.     { 2, "CCAM not loaded, Resident manager must be installed prior to using this utility." },          /* CASNOHWN        */
  53.     { 3, "Not enough memory - unload some TSRs or reduce BUFFERS in CONFIG.SYS." },                     /* CASNOMEM        */
  54.     { 2, "Cannot run diagnostics while board is active. Try again later." },                            /* CASDIAG         */
  55.     { 2, "Hardware error." },                                                                            /* CASHW           */
  56.     { 2, "Error sending file." },                                                                       /* CASSEND         */
  57.     { 2, "An error was encountered while trying to get the External Data Block." },                     /* CASNOEDB        */
  58.     { 2, "Cannot open Task Control File - check the task number and try again." },                      /* CASNOTCF        */
  59.     { 2, "Cannot open Receive Control File - check the task number and try again." },                   /* CASNORCF        */
  60.     { 2, "Cannot open Log Control File - check the task number and try again." },                       /* CASNOLCF        */
  61.     { 3, "Cannot create temporary file - check disk space available." },                                /* CASCREATETEMP   */
  62.     { 3, "Cannot open temporary file." },                                                                /* CASOPENTEMP     */
  63.     { 1, "Invalid date specified - be sure to give date as mm/dd/yy (month/day/year)." },               /* CASBADDATE      */
  64.     { 1, "Invalid time specified - be sure to give time as hh/mm ((24)hour/minute)." },                 /* CASBADTIME      */
  65.     { 1, "You must specify at least one file name." },                                                  /* CASARGFILE      */
  66.     { 1, "You must specify a path name." },                                                             /* CASARGPATH      */
  67.     { 1, "Only one path name can be specified." },                                                      /* CASARGMULTPATH  */
  68.     { 2, "Unable to cancel pending event." },                                                           /* CASNOCAN        */
  69.     { 2, "No currently executing event to cancel." },                                                   /* CASNOEVENT      */
  70.     { 2, "Error encountered while trying to delete the Task Queue." },                                  /* CASDELTQ        */
  71.     { 2, "Error encountered while trying to delete the Log Queue." },                                   /* CASDELLQ        */
  72.     { 2, "Error encountered while trying to delete the Receive Queue." },                               /* CASDELRQ        */
  73.     { 2, "Cannot delete event - check the task number and try again." },                                /* CASDELJOB       */
  74.     { 3, "Cannot open cover page file - check the path and filename and try again." },                  /* CASOPENCOVER    */
  75.     { 3, "Cannot move file - check disk space available." },                                            /* CASMOVE         */
  76.     { 3, "Specified path must exist - create the directory and try again." },                           /* CASNOPATH       */
  77.     { 3, "Unable to change current directory." },                                                        /* CASNODIR        */
  78.     { 3, "Unable to retreive current directory." },                                                      /* CASNOCURDIR     */
  79.     { 3, "Unable to load/unload FREIZE - make sure FRIEZE.UTL is in the connect dir." },                /* CASNOFREIZE     */
  80.     { 0, "NOT USED IN THIS VERSION." },                                                                  /* CASBADPORT      */
  81.     { 0, "NOT USED IN THIS VERSION." },                                                                  /* CASBADDRIVER    */
  82.     { 1, "Invalid switch specified on command line - check and try again (/? for help)." },             /* CASBADARG       */
  83.     { 2, "Unable to determine Autoreceive State - make sure CCAM is correctly installed." },            /* CASBADARS       */
  84.     { 3, "Cannot redirect output to specified file - check disk space available." },                    /* CASBADREDIR     */
  85.     { 3, "Cannot determine current working directory." },                                               /* CASBADCWD       */
  86.     { 1, "Event specified is not a File Transfer - check event number and try again." },                /* CASNOTFT        */
  87.     { 1, "Event specified is not a Fax - check event number and try again." },                          /* CASNOTFAX       */
  88.     { 3, "Cannot open log output file." },                                                              /* CASBADLF        */
  89.     { 1, "Specified file(s) not PCX, DCX, or ASCII - cannot FAX binary file." },                        /* CASBADFAXFILE   */
  90.     { 1, "Logo files must be of PCX type - specify correct file and try again." },                      /* CASBADLOGOFILE  */
  91.     { 1, "Cover files must be of ASCII type - specify correct file and try again." },                   /* CASBADCOVERFILE */
  92.     { 1, "Cannot find specified file(s) - check names and try again." },                                /* CASBADFILEARG   */
  93.     { 1, "Cannot find ASCII file." },                                                                   /* CASOPENASCII    */
  94.     { 1, "Cannot find PCX file." },                                                                     /* CASOPENPCX      */
  95.     { 1, "Cannot find DCX file." },                                                                     /* CASOPENDCX      */
  96.     { 2, "The specified file has already been saved." },                                                /* CASPRIORMOVE    */
  97.     { 2, "Nothing found to save."},                                                                     /* CASNOMOVE       */
  98.     { 2, "Unable to cancel current event."},                                                            /* CASNOCUR        */
  99.     { 3, "Printer timed out - check power to printer and try again." },                                 /* CASNOPRINTER    */
  100.     { 3, "Printer I/O error - check printer and try again." },                                          /* CASBADIO        */
  101.     { 3, "Printer out of paper." }                                                                      /* CASNOPAPER      */
  102. };
  103.  
  104. /* CAS errors (exit code field is the CAS error number). */
  105. ERRORMSG CASErrorMsg[] = {
  106.     { 0x0000, "" },
  107.     { 0x0002, "Image file is corrupted." },
  108.     { 0x0003, "File was sent, but it might contain errors." },
  109.     { 0x0004, "Receive data lost." },
  110.     { 0x0005, "Invalid or missing logofile." },
  111.     { 0x0006, "File name doesn't match NSF header." },
  112.     { 0x0007, "File size doesn't match NSF header." },
  113.     { 0x0200, "Internal error. Task switch failed." },
  114.     { 0x0201, "Unknown command.." },
  115.     { 0x0202, "Event not found." },
  116.     { 0x0203, "Tried to findnext with previous findfirst." },
  117.     { 0x0204, "No more events." },
  118.     { 0x0207, "Unknown schedule division." },
  119.     { 0x0208, "Bad event control file." },
  120.     { 0x0209, "Connection CoProcessor is busy." },
  121.     { 0x020A, "Invalid PCAM parameter." },
  122.     { 0x020B, "Can't uninstall PCAM." },
  123.     { 0x020C, "File already exists." },
  124.     { 0X0280, "Unknown task type." },
  125.     { 0X0281, "Bad phone number." },
  126.     { 0X0282, "Bad .PCX file header." },
  127.     { 0X0283, "Unexpected end of file." },
  128.     { 0X0284, "Phone line disconnected during event." },
  129.     { 0x0285, "Exceeded maximum dialing retries." },
  130.     { 0X0286, "No files specified to send." },
  131.     { 0X0287, "Connection CoProcessor isn't responding." },
  132.     { 0X0288, "More than 1023 pages of receive data." },
  133.     { 0X0289, "Manual connect posted too long ago." },
  134.     { 0X028A, "Connection CoProcessor command set error." },
  135.     { 0X028B, "Bad NSF header file." },
  136.     { 0X0401, "Remote unit not Group 3 compatible." },
  137.     { 0X0402, "Remote unit didn't send its capabilities." },
  138.     { 0X0403, "Remote unit requested disconnect." },
  139.     { 0X0404, "Remote unit isn't a CCP." },
  140.     { 0X0405, "Exceeded retrain or fax resend limit." },
  141.     { 0X0406, "Line noise or CCP & remote don't agree on bit rate." },
  142.     { 0X0407, "Remote unit disconnected after receiving data." },
  143.     { 0X0408, "No reply from remote unit after sending data." },
  144.     { 0X0409, "Capabilities of remote unit aren't compatible." },
  145.     { 0X040B, "Invalid reply from remote unit after sending data." },
  146.     { 0X040D, "Phone line dead or remote unit disconnected." },
  147.     { 0X0411, "Invalid command from remote after receiving data." },
  148.     { 0X0415, "Tried to receive from incompatible hardware." },
  149.     { 0X041F, "Unexpected end of file while receiving." },
  150.     { 0X045C, "Receive buffer overflowed while receiveing." },
  151.     { 0X045D, "Remote unit unexpectedly stopped sending data." },
  152.     { 0X045E, "Remote unit didn't send any data." },
  153.     { 0X045F, "Remote unit took too long to send fax scan line." },
  154.     { 0X0463, "Can't get through to remote unit." },
  155.     { 0X0464, "User canceled event." }
  156. };
  157.  
  158.  
  159.  
  160. void CASError(int ErrorNumber, int Fatal, int HwENumber, int Action)
  161. {
  162.     int x;
  163.  
  164.     /* Print the application error message. */
  165.     fprintf(stderr, "%s\n", ErrorMsg[ErrorNumber].Message );
  166.  
  167.     /* If a CAS error was specified, look it up and print it! */
  168.     if(HwENumber != 0) {
  169.         for(x = 1; x < UpperBound(CASErrorMsg); x++) {
  170.             if(CASErrorMsg[x].ExitCode == HwENumber) {
  171.                 fprintf(stderr, "%s\n", CASErrorMsg[x].Message);
  172.                 break;
  173.             }
  174.         }
  175.     }
  176.  
  177.     /* If error was fatal, exit with DOS exit code. */
  178.     if(Fatal)
  179.         exit(ErrorMsg[ErrorNumber].ExitCode);
  180.  
  181. }
  182.